<?php
if(isset($_GET['pixbox'])){ /*return pixbox script*/
  if(isset($_GET['js'])){ $js=true; }
  else{ $js=false; }
  $pixbox=$_GET['pixbox'];
  $pixpath="../images/$pixbox/";

  if(!$js){
    echo'
<a href="#" onclick="prevpic();">&lt;&lt;</a>
<a href="#" onclick="nextpic();">&gt;&gt;</a>
    ';    //<h4>Contents of ',$pixbox.'</h4>     ,implode('<br/>',$pixarray);
  }
  else{
    echo'
nextpic=function(){
  if(window.pixi<window.pixcount){ window.pixi+=1; }
  else{ window.pixi=0; }
  changepic();
}

prevpic=function(){
  if(window.pixi>0){ window.pixi-=1; }
  else{ window.pixi=window.pixcount; }
  changepic();
}

changepic=function(){
  var pixid=document.getElementById("pixbox");
  pixid.src="plugin/pixbox/images/"+window.pixbox+"/"+window.pixs[window.pixi];
  pixid.alt=window.pixs[window.pixi];
  document.getElementById("pixlabel").innerHTML=(window.pixi+1)+": "+pixid.src.substr(pixid.src.lastIndexOf("/")+1);
  if(window.popped){ pixpop(pixid); }
  //alert(window.pixi + \':\' + window.pixs[window.pixi]);
}

window.pixbox="',$pixbox,'";
window.pixcount=',$pixcount-1,';
window.pixi=0;
window.pixs=new Array();';
    $pixi=0;
    foreach ($pixarray as $pic) {
      echo'window.pixs[',$pixi,']="',$pic,'";';
      ++$pixi;
    }
//echo'alert(window.pixcount);';
//echo'alert(pixs[0]);';
  }
}
?>

















<?php
global $pixbox;
$pixbox=(isset($_GET['p'])?$_GET['p']:(isset($_POST['p'])?$_POST['p']:'pixbox'));
echo'/* PHP temp<p/>'.$pixbox.'*/';
//bedrijven extra belasting op reclameinkomsten laten betalen dmv heffing op de |bandbreedte die ze aanbieden/|
/*/echo dirname(__FILE__);
echo __FILE__;*/

if($handle=opendir($path)){
  while(false!==($file=readdir($handle))){
    if(substr($file,0,1)!='.'){ echo' <a href="#p" onclick="getpixbox(this);">',$file,'</a>';
  }}closedir($handle); }
/*****************
 /temporary array
*****************/
  
function pic(){
global$pixbox;
$pixpath=dirname(__FILE__).'/images/'.$pixbox;
echo$pixpath;
//echo '<img src="'.__FILE__."$pixbox> alt=\"$pixbox\"/>";

$pixarray=array();
if($handle=opendir($pixpath)){
$pixcount=0;
while(false!==($file=readdir($handle))){
  if(substr($file,0,1)!='.'){
    ++$pixcount;
    $pixarray[]=$file;
  }
  }closedir($handle); }
}
//hier moe een file gewrite worden

?>


<a name="p"></a>
<?php pic()?>


<script type="text/javascript">//<![CDATA[
<?php /*/ ya whsds echo"var pixbox='$pixbox';";*/ ?>
//ajaxjs('plugin/pixbox/cms/show.php');
alert("js:"+pixbox);

function pixpop(el){
  if(window.popped){
    el.width=200;
    el.height=200;
    el.style.position='static';
    window.popped=false;
  }
  else{
    el.width=el.naturalWidth;
    el.height=el.naturalHeight;
    el.style.position='absolute';
    el.top=(windowheight()*0.5)-(el.naturalHeight*0.5);
    el.left=(windowwidth()*0.5)-(el.naturalWidth*0.5);;
    window.popped=true;
  }
}

function windowwidth() {
  var myWidth=0;
  if(typeof(window.innerWidth)=='number'){
    myWidth=window.innerWidth;     //Non-IE
  }
  else if(document.documentElement && document.documentElement.clientWidth){
    myWidth=document.documentElement.clientWidth; //IE 6+ in 'standards compliant mode'
  }
  else if(document.body && document.body.clientWidth){
    myWidth=document.body.clientWidth;     //IE 4 compatible
  }
  return myWidth;
}

function windowheight() {
  var myHeight=0;
  if(typeof(window.innerHeight)=='number'){
    myHeight=window.innerHeight;    //Non-IE
  }
  else if(document.documentElement && document.documentElement.clientHeight){
    myHeight=document.documentElement.clientHeight;    //IE 6+ in 'standards compliant mode'
  }
  else if(document.body && document.body.clientHeight){
    myHeight=document.body.clientHeight;     //IE 4 compatible
  }
  return myHeight;
}

function getpixbox(el){
  ajaxjs('plugin/pixbox/cms/show.php?js=1&pixbox='+el.innerHTML);
  ajax('pixboxlist','plugin/pixbox/cms/show.php?pixbox='+el.innerHTML);
  nextpic(); //function fetched thru ajax (runs too late)
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function ajaxjs(cmd){
  if (window.XMLHttpRequest){ var xmlhttp=new XMLHttpRequest(); }
  else{ var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
  xmlhttp.onreadystatechange=function(){
    if (xmlhttp.readyState==4 && xmlhttp.status==200){
      eval(xmlhttp.responseText); }}
  xmlhttp.open("GET",cmd,true);
  xmlhttp.send();
}

function ajax(adiv,cmd){
  if (window.XMLHttpRequest){ var xmlhttp=new XMLHttpRequest(); }
  else{ var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
  xmlhttp.onreadystatechange=function(){
    if (xmlhttp.readyState==4 && xmlhttp.status==200){
      document.getElementById(adiv).innerHTML=xmlhttp.responseText; }}
  xmlhttp.open("GET",cmd,true);
  xmlhttp.send();
}
//]]></script>
